@extends('layout.template')

@section('title')
	{{ $title }}
@stop

@section('content')

<div class="row">
	<div class="col-xs-12">
		@if(Session::has('message'))
			<div class="alert alert-success"><i class="fa fa-bullhorn"></i> {{ Session::get('message') }}</div>
		@endif

		@if($errors -> has())
			<div class="alert alert-warning">			
			@foreach($errors -> all() as $err)
				<li>{{ $err }}</li>
			@endforeach	
			</div>
		@endif	
	</div>
</div>

<div class="row" style='margin-bottom: 10px'>
	<div class="col-xs-12">
		<button id='create' class="btn btn-primary btn-sm"><i class='fa fa-hand-o-right'></i> Toggle</button>
	</div>	
</div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script type="text/javascript">
	$(document).ready(function(){
	$("#create").click(function(){
		$("#form").toggle(500);		
	});
		$("#form").hide();		
	});
</script>

<style type="text/css">
	form input{	
		margin-bottom: 10px;	
	}
</style>


<div class="panel panel-default" id='form'>
	<div class="panel-heading">
		<h3 class="panel-title">Add a API</h3>
	</div>
	<div class="panel-body">
		<div class="row" style='padding-bottom: 10px'>
			<div class="col-xs-12">		
				{{ Form::open(array('url' => 'admin/apis/create'))}}	
				<div class="form-group">
					<label for="api_key"><i class="icon-user"></i> <b>API KEY</b></label>
					{{ Form::text('api_key', null, array('class' => 'form-control')) }}
				</div>	
				<div class="form-group">
					<label for="network_id"><i class="icon-user"></i> <b>Network Id</b></label>
					{{ Form::text('network_id', null, array('class' => 'form-control')) }}
				</div>				
				{{ Form::submit('Submit', array('class' => 'btn btn-primary btn-sm'))}}	
				{{ Form::close() }}	
			</div>
		</div>
	</div>
</div>

<div class='row' style='padding-top: 5px'>
	<div class="col-xs-12">
		<table class="table table-hover table-condensed">
			<tr>
				<th>#</th>				
				<th>API KEY</th>
				<th>Network ID</th>
				<th></th>														
			</tr>
			@foreach($apis as $api)
			<tr>				
				<td style='width: 50px;'>{{ $api -> id }}</td>			
				<td>{{ $api -> api_key }}</td>
				<td>{{ $api -> network_id }}</td>				
				<td>								
					<a href='destroy/{{$api -> id}}' class='btn btn-danger btn-xs'><i class='fa fa-trash-o'></i></a>	
				</td>									
			</tr class='ph'>
			@endforeach
		</table>
		<div style='text-align: center;'>	
			{{ $apis -> links() }}
		</div>
	</div>
</div>
@stop
